#pragma once
/*!
 * \file 
 * IVideoDecoder.h
 */

#define MAX_CODEC_COUNT		4
/*!
 * \brief Interface class for decoding video stream.
 *
 * class for video decoder interface.
 *
 * - header file: IVideoDecoder.h.
 * - lib: VidCodec.lib.
 * - DLL: VidCodec.dll.
 */

class AFX_EXT_CLASS IVideoDecoder
{
public:
	enum _TAG_CODEC_ID
	{
		_ID_MJPEG = 0,
		_ID_MPEG4,
		_ID_H264
	};

public:
	/*!
	 * Create Video Decoder Object
	 * @return Video Decoder Object if NULL, video decoder cannot be used.
	 * @param nCodecType
	 *
	 *	if nCodecType = 0, decoder for test purpose,
	 *	if nCodecType = 1, H.264 codec of Pixtree,
	 *	if nCodecType = 2, FFMpeg decoder
	 *
	 * @param nDecoder the number of decoder, usually sets 1
	 * 
	 */
	static IVideoDecoder *Create(int nCodecType, int nDecoder);
	IVideoDecoder(void);
	IVideoDecoder(int nDecoder);
	virtual ~IVideoDecoder(void);

protected:
	int m_nDecoderCnt;
	int m_nCodecID;
	BOOL m_bDeinterlace;
	CRITICAL_SECTION	m_cs;

	int m_nBrightness;
	int m_nContrast;
	int m_nSaturation;


	int m_nSharpeness;
	int m_nBlur;

public:
	/**
	 * Initialize video decoder and its resources
	 * The decoder supports H.264
	 * @return if TRUE, The video decoder initializes successfully.
	 */
	virtual BOOL InitCodec();
	virtual BOOL InitCodec(int nCodecID);
	/**
	 * Release video decoder and its resources
	 */
	virtual void ReleaseCodec();
	/**
	 * Decode the compressed video packet
	 * @return if TRUE, decoding is successfully done
	 * 
	 * @param dwChannel the channel number, this number is less then nDecoder of IVideoDecoder::Create
	 * @param pVidStream buffer pointer of compressed video packet
	 * @param nWidth returns the value of image width
	 * @param nHeight returns the value of image height
	 * @param nSize size of compressed video packet
	 * @param pFrame returns the decompressed image buffer
	 *
	 */
	virtual BOOL Decode(DWORD dwChannel, BYTE* pVidStream, int* nWidth, int* nHeight, int nSize, BYTE* pFrame);

	/**
	 * Reset video decoder and its resources
	 * 
	 * @return if TRUE, the video decoder resets successfully
	 * 
	 * @param dwChannel the channel number, this number is less then nDecoder of IVideoDecoder::Create
	 */
	virtual BOOL ResetCodec(DWORD dwChannel);
	virtual BOOL ApplyDeInterlaceFilter(BOOL bApply);

	/**
	 * Control brightness of the decompressed image
	 * 
	 * @param nBrightness the value of brightness which ranges between 0(%, darkest) to 100(%), default value is 50(%)
	 */
	virtual void SetBrightness(int nBrightness);		//range 0 to 100
	/**
	 * Control contrast of the decompressed image
	 * 
	 * @param nContrast the value of contrast which ranges between 0(%) to 100(%), default value is 50(%)
	 */
	virtual void SetContrast(int nContrast);			//range 0 to 100
	/**
	 * Control saturation of the decompressed image
	 * 
	 * @param nSaturation the value of saturation which ranges between 0(%, no color) to 100(%), default value is 50(%)
	 */
	virtual void SetSaturation(int nSaturation);		//range 0 to 100

	virtual void SetSharpeness(int m_nSharpeness);		//range 0 to 100
	virtual void SetBlur(int nBlur);				
};

